<template>
	<view class="container">
		<navbar :title="scrollTop > 10?'个人中心':''" :isBack="false"></navbar>
		<view class="main" :style="{paddingTop: getNavbarHeight()  + 'px'}">
			<!-- 用户信息 -->
			<userInfo></userInfo>
			<!-- 积分商城 -->
			<customIntegral></customIntegral>
			<!-- 客服 -->
			<customerService></customerService>
			<!-- 订单 -->
			<customOrder></customOrder>
			<!-- 分销 -->
			<customDistribution></customDistribution>
			<!-- 其它 -->
			<customOther></customOther>
			<!-- 推荐列表 -->
			<recommendation-list></recommendation-list>
			<view class="safe-area-inset-bottom"></view>
		</view>
		<tabbar :current="4"></tabbar>
	</view>
</template>

<script setup>
	import userInfo from './components/user-info.vue'
	import customIntegral from './components/custom-integral.vue'
	import customerService from './components/customer-service.vue'
	import customOrder from './components/custom-order.vue'
	import customOther from './components/custom-other.vue'
	import customDistribution from './components/custom-distribution.vue'
	import { onLoad, onPageScroll, onShow } from '@dcloudio/uni-app'
	import { getNavbarHeight } from '@/utils/system.js'
	import { ref, computed } from 'vue'
	import useUserStore from '@/store/modules/user.js'
	import { waitForAppLaunch } from '@/utils/common.js'

	const scrollTop = ref(0)
	const userStore = useUserStore()
	const isLogin = computed(() => Boolean(userStore.token));

	onLoad(() => {
		// #ifndef MP-WEIXIN
		uni.hideTabBar();
		// #endif
	})

	onShow(async () => {
		await waitForAppLaunch()
		if (!isLogin.value) return;
		userStore.getUserInfo()
	})

	// 监听滚动事件
	onPageScroll((e) => {
		scrollTop.value = e.scrollTop
	})
</script>

<style>
	page {
		background-color: #F5F5F5;
	}
</style>
<style lang="scss" scoped>
	.container {
		.main {}
	}
</style>